import { ApiProperty } from '@nestjs/swagger';
import { Exclude } from 'class-transformer';
import { PrimaryGeneratedColumn, Column, Entity } from 'typeorm';
export enum StatusContent {
  Publish = 'publish',
  Draft = 'draft',
}
@Entity()
export class Page {
  @ApiProperty({ description: 'id' })
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @ApiProperty({ description: '页面名' })
  @Column({
    comment: '页面名',
    unique: true,
    length: 50,
    default: null,
  })
  name: string;

  @ApiProperty({ description: '路径地址' })
  @Column({
    comment: '路径地址',
    unique: true,
    length: 50,
    default: null,
  })
  path: string;

  @ApiProperty({ description: '排序' })
  @Column({ type: 'int', comment: '排序', default: 0 })
  order: number;

  @ApiProperty({ description: '评论开启 true - 开启 , false - 禁用' })
  @Column({
    comment: '评论开启 true - 开启 , false - 禁用',
    default: true,
  })
  isCommentOpen: boolean;

  @ApiProperty({ description: '内容' })
  @Exclude()
  @Column({ type: 'text', comment: '内容', default: null })
  content: string;

  @ApiProperty({ description: 'markdown 转 html,自动生成' })
  @Exclude()
  @Column({
    comment: 'markdown 转 html,自动生成',
    type: 'mediumtext',
    default: null,
  })
  contentHtml: string;

  @ApiProperty({ description: '状态' })
  @Column('simple-enum', { comment: '状态', enum: ['draft', 'publish'] })
  status: string;

  @ApiProperty({ description: '视图' })
  @Column({ type: 'int', comment: '视图', default: 0 })
  views: number;

  @ApiProperty({ description: '出版时间' })
  @Column({ comment: '出版时间', type: 'timestamp', default: null })
  publishTime: Date;

  @ApiProperty({ description: '创建时间' })
  @Column({
    type: 'timestamp',
    comment: '创建时间',
    default: () => 'CURRENT_TIMESTAMP',
  })
  createTime: Date;

  @ApiProperty({ description: '修改时间' })
  @Column({
    type: 'timestamp',
    comment: '修改时间',
    default: () => 'CURRENT_TIMESTAMP',
  })
  updateTime: Date;
}
